<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:ui="http://java.sun.com/jsf/facelets"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:f="http://java.sun.com/jsf/core"
      xmlns:c="http://java.sun.com/jsp/jstl/core">

    <ui:composition template="/template.xhtml">
        <ui:define name="title">
            <h:outputText value="#{bundle.ViewExpensesTitle}"></h:outputText>
        </ui:define>
        <ui:define name="body">
            <h:panelGroup id="messagePanel" layout="block">
                <h:messages errorStyle="color: red" infoStyle="color: green" layout="table"/>
            </h:panelGroup>
            <h:form>
                <h:panelGrid columns="2">
                    
                    <h:outputText value="#{bundle.ViewExpensesLabel_expenseType}"/>
                    <h:outputText value="#{expensesController.selected.expenseType}" title="#{bundle.ViewExpensesTitle_expenseType}"/>
                    
                    <h:outputText value="#{bundle.ViewExpensesLabel_expenseDate}"/>
                    <h:outputText value="#{expensesController.selected.expenseDate}" title="#{bundle.ViewExpensesTitle_expenseDate}">
                        <f:convertDateTime pattern="MM/dd/yyyy" />
                    </h:outputText>
                    
                    <h:outputText value="#{bundle.ViewExpensesLabel_task}"/>
                    <h:outputText value="#{expensesController.selected.task}" title="#{bundle.ViewExpensesTitle_task}"/>
                    
                    <h:outputText value="#{bundle.ViewExpensesLabel_reimbursable}"/>
                    <h:outputText value="#{expensesController.selected.reimbursable}" title="#{bundle.ViewExpensesTitle_reimbursable}"/>
                    
                    <h:outputText value="#{bundle.ViewExpensesLabel_units}"/>
                    <h:outputText value="#{expensesController.selected.units}" title="#{bundle.ViewExpensesTitle_units}"/>
                    
                    <c:if test="${type=='admin'}">
                    <h:outputText value="#{bundle.ViewExpensesLabel_createdAt}"/>
                    <h:outputText value="#{expensesController.selected.createdAt}" title="#{bundle.ViewExpensesTitle_createdAt}">
                        <f:convertDateTime pattern="MM/dd/yyyy" />
                    </h:outputText>
                    </c:if>
                    
                    <h:outputText value="#{bundle.ViewExpensesLabel_status}"/>
                    <h:outputText value="#{expensesController.selected.status}" title="#{bundle.ViewExpensesTitle_status}"/>
                    
                    <h:outputText value="#{bundle.ViewExpensesLabel_project}"/>
                    <h:outputText value="#{expensesController.selected.project.projectName}" title="#{bundle.ViewExpensesTitle_project}"/>
                    
                    <c:if test="${type=='admin'}">
                    <h:outputText value="#{bundle.ViewExpensesLabel_employee}"/>
                    <h:outputText value="#{expensesController.selected.employee.businessEmail}" title="#{bundle.ViewExpensesTitle_employee}"/>
                    </c:if>
                    
                    <h:outputText value="#{bundle.ViewExpensesLabel_currency}"/>
                    <h:outputText value="#{expensesController.selected.currency}" title="#{bundle.ViewExpensesTitle_currency}"/>
                    
                    <c:if test="${type=='admin'}">
                    <h:outputText value="#{bundle.ViewExpensesLabel_createdBy}"/>
                    <h:outputText value="#{expensesController.selected.createdBy.businessEmail}" title="#{bundle.ViewExpensesTitle_createdBy}"/>
                    </c:if>
                </h:panelGrid>
                <br />
                <h:commandButton rendered="#{expensesController.selected.status != 'submitted'}" action="#{expensesController.destroyAndView}" type="submit" value="#{bundle.ViewExpensesDestroyLink}"/>
                <h:commandButton rendered="#{expensesController.selected.status != 'submitted'}" action="Edit" value="#{bundle.ViewExpensesEditLink}" immediate="true" type="submit"/>
            </h:form>
            
            <h:form>
                &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                <h:commandButton action="#{expensesController.prepareCreate}" type="submit" value="#{bundle.ViewExpensesCreateLink}" />
                <h:commandButton rendered="${type=='admin'}" action="#{expensesController.prepareList}" type="submit" value="#{bundle.ViewExpensesShowAllLink}"/>
                <h:commandButton rendered="${type=='user'}" action="#{expensesController.listUserExpenses}" type="submit" value="#{bundle.ViewExpensesShowAllLink}"/>
                <h:button rendered="${type=='admin'}" value="Back to Home" outcome="/index" />
                <h:button rendered="${type=='user'}" value="Back to Home" outcome="/userhome"/>

            </h:form>
        </ui:define>
    </ui:composition>

</html>
